/**
 * Created by CFlower on 2017/9/20.
 */

var type = 1;					// 0:电类传感器；1:FBG温度；2：FBG应力；3：CCD
var subType=5;					// 机床信息类型 0:轴坐标 1:轴功率 2:轴负荷 5:未选择
var picName = "传感器数值";
var danwei = '\u2103';
var myChart = null;

    $(function() {
    var dom = document.getElementById("e_container");
    myChart = echarts.init(dom);
    myChart.setOption(option = {
        title: {
            text: '数据对比图',
            x: 'left'
        },
        xAxis : [{
                type : 'time',
                splitNumber:10,
                boundaryGap: false,
            }],
        yAxis: {
            type: 'value',
            name: '未选择',
            scale: true,
            splitLine: {
                show: false
            }
        },
        toolbox: {
            left: 'center',
            feature: {
                dataZoom: {
                    yAxisIndex: 'none'
                },
                restore: {},
                saveAsImage: {}
            }
        },
        dataZoom: [{
            type: 'slider',
            show : true,
            realtime: true,
            start: 30,
            end:70
        }, {
                type: 'inside',
                start: 30,
                end: 70

        }],
        tooltip: {
            // formatter : function (params) {
            //     var temp=setAxisTitle();
            //     return params.seriesName + ' :<br/>'
            //         + params.value[1] + temp[1];
            // }
            trigger: 'axis',
            axisPointer: {
                type: 'cross',
                label: {
                    backgroundColor: '#283b56'
                }
            }
        },
        // axisPointer: {
        //     link: {xAxisIndex: 'all'}
        // },
        // visualMap: {
        //     min: -10,
        //     max: 50,
        //     inRange: {
        //         color: ['lightskyblue','yellow', 'orangered']
        //     }
        // },
        series: [{
            name:'未选择',
            type:'line',
            data: (function () {
                var d = [];
                var time = (new Date()).getTime(), i;
                for (i = -6; i <= 0; i += 1) {
                    d.push([
                        time + i * 1000,
                        0
                    ]);
                }
                return d;
            })()
        }]
    });


    function setAxisTitle() {
        switch(type) {
            case 0:
                picName = "电类温度";				// 电类温度查询页面
                danwei = '\u2103';
                break;
            case 1:
                picName = "FBG温度";				// FBG温度查询页面
                danwei = '\u2103';
                break;
            case 2:
                picName = "FBG应力";				// FBG应力查询页面
                danwei = '\u2103';
                break;
            case 3:
                picName = "CCD位移";				// CCD查询页面
                danwei = "mm";
                break;
            case 4:								// 功率查询页面
                switch (subType){
                    case 0:picName = "坐标";danwei = "mm";break;
                    case 1:picName = "功率";danwei = "A";break;
                    case 2:picName = "负荷";danwei = "%";break;
                    default:picName = "未选择";danwei = "";break;
                }
                break;
            case 5:								// 历史查询页面
                picName = "未选择";
                danwei = "";
                break;
            default:							// 崩坏的情况
                picName = "未选择";
                danwei = "";
                break;
        }
        return new Array(picName,danwei);
    }


});